<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Gentelella Alela! | </title>

    <!-- Bootstrap -->
    <link href="/resources/gentelella/vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="/resources/gentelella/vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <!-- NProgress -->
    <link href="/resources/gentelella/vendors/nprogress/nprogress.css" rel="stylesheet">
    <!-- iCheck -->
    <link href="/resources/gentelella/vendors/iCheck/skins/flat/green.css" rel="stylesheet">

    <!-- bootstrap-progressbar -->
    <link href="/resources/gentelella/vendors/bootstrap-progressbar/css/bootstrap-progressbar-3.3.4.min.css" rel="stylesheet">
    <!-- JQVMap -->
    <link href="/resources/gentelella/vendors/jqvmap/dist/jqvmap.min.css" rel="stylesheet"/>
    <!-- bootstrap-daterangepicker -->
    <link href="/resources/gentelella/vendors/bootstrap-daterangepicker/daterangepicker.css" rel="stylesheet">

    <!-- Custom Theme Style -->
    <link href="/resources/gentelella/css/custom.min.css" rel="stylesheet">
    <link rel="stylesheet" href="/resources/datatables/dataTables.bootstrap.css?v=2">
    <link href="/resources/gentelella/vendors/datatables.net-bs/css/dataTables.bootstrap.min.css" rel="stylesheet">
    <link href="/resources/paginator/css/bootstrap-combined.min.css" rel="stylesheet">
    <link href="/resources/css/self.css" rel="stylesheet">
    <!-- table -->
    <script type="text/javascript" src="/resources/My97DatePicker/WdatePicker.js"></script>
    <script src="/resources/js/jquery-1.11.1.min.js"></script>
    <script src="/resources/datatables/jquery.dataTables.min.js"></script>
    <script src="/resources/datatables/dataTables.bootstrap.min.js"></script>
    <script src="/resources/paginator/js/bootstrap-paginator.js"></script>
    <script src="/resources/js/self.js"></script>
    <script src="/resources/gentelella/vendors/bootstrap/js/modal.js"></script>
    <style type="text/css">
        .form-data{
            width: 150px !important;
        }
    </style>
</head>

<body>
<div class="col-md-12">
    <div class="box-body" style="padding-bottom:10px;">
        <div class="row form-inline" style="margin-left: 20px;">

            <!--  <div class="form-group">
                  <input type="hidden" class="form-control form-data" name="process"/>
                  <input type="hidden" class="form-control form-data" name="refuseFlag"/>
                  <label>名称:</label>
                  <input type="text" class="form-control form-data" name="name"/>
              </div>-->


            <div class="form-group">
                <label>姓名:</label>
                <input type="text" class="form-control form-data" name="name"/>

            </div>

            <button type="button"  onclick="searchData()" class="btn btn-primary">查询</button>


        </div>

    </div>
    <div class="x_panel">

        <table id="example" class="table table-bordered table-striped dataTable" cellspacing="0" width="100%">
            <thead>
            <tr>
                <th>选择</th>

                <th>名称</th>
                <!--<th>名称</th>-->
                <th>状态</th>
                <th>易制毒化学品管理监督检查表</th>
                <th>剧毒化学品从业单位安全检查记录表</th>
                <th>操作</th>
            </tr>
            </thead>
        </table>
        <div id="example_page">
        </div>
    </div>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <input type="hidden" id="pc_id"  />
                <input type="hidden" name="process" value="feedback">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    上报
                </h4>
            </div>
            <div class="modal-body">

                <div>
                    <textarea  rows="5" style="width:100%;" id="companyRemark"></textarea>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" onclick="policeCheck()">
                    确定
                </button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                </button>

            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>

</body>
<script type="text/javascript">
    //列名称
    var columns = ["id","name","process","table1","table2","id"];
    var createdCellFun = function (td, cellData, rowData, row, col) {
        /* $(td).css('color', 'red');*/
        switch (col){
            case 0:
                var html = "";
                if(rowData.pullFlag =='n'){

                }

                html += "<input type='checkbox' value='"+cellData+"' name='select' />";

                $(td).html(html);
                break;

            case 2:
                $(td).html(getProcessName(cellData));
                break;
            case 3:
                var html = "";
                if(!isNullOrUndefined(cellData)){
                    html = "<a href='javascript:void(0);' onclick='editTable1(\""+cellData+"\")' >查看</a>";
                }else {
                    html = "";
                }
                $(td).html(html);
                break;
            case 4:
                if(!isNullOrUndefined(cellData)){
                    html = "<a href='javascript:void(0);' onclick='editTable2(\""+cellData+"\")' >查看</a>";
                }else {
                    html = "";
                }
                $(td).html(html);
                break;

            case 5:
                var html = "";
                html += "<a href='javascript:void(0);' onclick='show(\""+cellData+"\")' >查看</a> &nbsp; &nbsp;";
                if(rowData.process == 'publish' ){
                    html += "<a href='javascript:void(0);' onclick='toReply(\""+cellData+"\")' >上报</a> &nbsp; &nbsp;";
                }
                $(td).html(html);
                break;

        }
    }
    $(function () {
        setTitle("警员管理");
        buildPage("#example");
        var param = getParam();
        initDataTable("#example", "/company/policeCheck/list.do",param,columns,createdCellFun);
    });
    function getParam(){
        var param = getPageDataByClass("form-data");

        param['page']= 1;
        param['size']= 10;
        return param;
    }
    function buildPage(element) {
        var param = getParam();
        //点击分页页面按钮
        var clickFun = function (e, originalEvent, type, page) {
            //构建查询参数
            param = getParam();
            param['size'] = 10;
            _page = page;
            param['page'] = page;
            initDataTable("#example", "/company/policeCheck/list.do", param, columns, createdCellFun);
        }
        $.ajax({
            url:"/company/policeCheck/count.do?_t=" + new Date().getTime(),
            data: param ,
            type:'post',
            dataType:"json",  //xml  html   script  jsonp
            success:function(result){
                initPage($("#example_page"),1,result.data,clickFun);
            }
        });
    }
    function searchData() {
        var param = getParam();
        initDataTable("#example", "/company/policeCheck/list.do", param, columns, createdCellFun);
        buildPage("#example");
    }


    //通用 获取列表中选择的数据的id
    function getSelectChecked() {
        var ids = [];
        $("input[name='select']:checked").each(function(){
            ids.push($(this).prop("value"));
        });
        return ids;
    }
    function getOneSelectChecked() {
        var ids = getSelectChecked();
        if(ids.length == 0 || ids.length > 1) {
            return null;
        }
        return ids[0];
    }
    function checkAllSelect(node) {
        if($(node).prop("checked")) {
            $("input[name='select']").each(function(){
                $(this).prop("checked", true);
            });
        } else {
            $("input[name='select']").each(function(){
                $(this).prop("checked", false);
            });
        }
    }
    function getProcessName(process) {
        var processName ="";
        if(process =='create'){
            processName ='新建'
        }else if(process =='publish'){
            processName ='发布'
        }else if(process =='feedback'){
            processName ='反馈'
        }else if(process =='finish'){
            processName ='完结'
        }
        return processName;
    }
    function show(id) {
        goto("police_check_show.html",{"id":id});
    }

    function policeCheck() {
        var id = $("#pc_id").val();
        var process= $("input[name='process']").val();
        var    companyRemark=  $("#companyRemark").val();
        $.ajax({
            url:"/company/policeCheck/audit.do?_t=" + new Date().getTime(),
            data: {"id":id,"process":process,"companyRemark":companyRemark} ,
            type:'post',
            dataType:"json",  //xml  html   script  jsonp
            success:function(result){
                $('#myModal').modal('hide');
                searchData();
            }
        });
    }
    function toReply(id) {
        $("#pc_id").val(id);
        $("#companyRemark").html("");
        $('#myModal').modal('show');

    }
    function  editTable2(id) {
        goto("police_check_table_two.html",{"id":id});
    }
    function addTable1() {
        goto("police_check_table_one.html",{});
    }

</script>
</html>